package cn.minsh.lims.eoms.modules.app.controller;

import cn.minsh.lims.eoms.common.utils.PageUtils;
import cn.minsh.lims.eoms.common.utils.R;
import cn.minsh.lims.eoms.modules.app.entity.PicEntity;
import cn.minsh.lims.eoms.modules.app.service.PicService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;


/**
 * 图片存储
 *
 * @author lht
 * @email sunlightcs@gmail.com
 * @date 2021-04-26 02:30:42
 */
@RestController
@RequestMapping("sys/pic")
public class PicController {
    @Autowired
    private PicService picService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:pic:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = picService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:pic:info")
    public R info(@PathVariable("id") Long id){
		PicEntity pic = picService.getById(id);

        return R.ok().put("pic", pic);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:pic:save")
    public R save(@RequestBody PicEntity pic){
		picService.save(pic);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:pic:update")
    public R update(@RequestBody PicEntity pic){
		picService.updateById(pic);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:pic:delete")
    public R delete(@RequestBody Long[] ids){
		picService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
